/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.telsoft.hms.lib.security.session;

import java.util.UUID;
import com.telsoft.hms.lib.security.hash.MD5;
import com.telsoft.hms.lib.security.core.AbstractSession;

/**
 * @author VIETPH hongvietmtb@gmail.com, vietph@telsoft.com.vn,
 * Ngày tạo: 12/09/2014
 * 
 */
public class Session extends AbstractSession {

    //<editor-fold desc="private String userId { get; set; }">
    private long userId;
    private String userName;
    private int languageCode;
    private String hospitalKey;

    public long getUserId() {
        return userId;
    }

    public void setUserId(long userId) {
        this.userId = userId;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public int getLanguageCode() {
        return languageCode;
    }

    public void setLanguageCode(int languageCode) {
        this.languageCode = languageCode;
    }
    //</editor-fold>

    //<editor-fold desc="private byte maxSessionAllowed { get; set; }">
    private int maxSessionAllowed;

    public int getMaxSessionAllowed() {
        if (maxSessionAllowed < 1) {
            maxSessionAllowed = 1;
        }
        return maxSessionAllowed;
    }

    public void setMaxSessionAllowed(int maxSessionAllowed) {
        if (maxSessionAllowed < 1) {
            maxSessionAllowed = 1;
        }
        this.maxSessionAllowed = maxSessionAllowed;
    }
    //</editor-fold>

    public Session(int sessionTimeout) {
        super(sessionTimeout);
        this.maxSessionAllowed = 1;
    }

    // hàm tạo ra Security Key, được gọi lúc khởi tạo đối tượng Session
    @Override
    protected String generateRandomSecurityKey() {
        return MD5.getMD5(UUID.randomUUID().toString() + "Hello Viet Nam");
    }

	public String getHospitalKey() {
		return hospitalKey;
	}

	public void setHospitalKey(String hospitalKey) {
		this.hospitalKey = hospitalKey;
	}
}
